package Class.Homemade.demo0525.demo3;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 姚东名
 * Date: 2024-05-25
 * Time: 21:49
 */
public class Computer {
    //电脑是主要的东西 -> 开机、关机
    public void open() {
        System.out.println("开机！");
    }
    public void close() {
        System.out.println("关机！");
    }
    //使用接口：
    public void useUsbDevice(USB usb) {
        //调用接口：打开接口
        usb.openDevice();
        if(usb instanceof Mouse) {
            //向下转型，因为接口不可以实例化对象
            Mouse mouse = (Mouse)usb;
        }else {
            KeyBoard keyBoard = (KeyBoard)usb;
        }
        //关闭接口：
        usb.closeDevice();
    }
}
